/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { Request, Response } from 'express';
import { ResponseItem, responseSuccess } from '../../utils';

import Mock, { mock } from 'mockjs';

export default {
  'POST /Front/getAllDepartment': (req: Request, res: Response) => {
    const data = [
      {
        id: '1',
        parentid: '0',
        name: '快宝网络',
        department_id: '1',
        created_at: '2022-03-09 15:49:30',
      },
      {
        id: '2',
        parentid: '1',
        name: '快宝驿站',
        department_id: '2',
        created_at: '2022-03-11 10:35:30',
      },
      {
        id: '3',
        parentid: '1',
        name: '人事行政部',
        department_id: '3',
        created_at: '2022-03-11 10:35:30',
      },
      {
        id: '4',
        parentid: '1',
        name: '产品部',
        department_id: '4',
        created_at: '2022-03-11 10:35:30',
      },
      {
        id: '5',
        parentid: '1',
        name: 'UI设计组',
        department_id: '6',
        created_at: '2022-03-11 10:35:30',
      },
      {
        id: '6',
        parentid: '1',
        name: '客服组',
        department_id: '7',
        created_at: '2022-03-11 10:35:30',
      },
      {
        id: '7',
        parentid: '1',
        name: '技术管理二组',
        department_id: '8',
        created_at: '2022-03-11 10:35:31',
      },
      {
        id: '8',
        parentid: '1',
        name: 'RN组',
        department_id: '9',
        created_at: '2022-03-11 10:35:31',
      },
      {
        id: '9',
        parentid: '1',
        name: '项目管理组',
        department_id: '10',
        created_at: '2022-03-11 10:35:31',
      },
      {
        id: '10',
        parentid: '1',
        name: '测试组',
        department_id: '11',
        created_at: '2022-03-11 10:35:31',
      },
      {
        id: '11',
        parentid: '1',
        name: '驿站组',
        department_id: '12',
        created_at: '2022-03-11 10:35:31',
      },
      {
        id: '12',
        parentid: '1',
        name: '寄件组',
        department_id: '13',
        created_at: '2022-03-11 10:35:31',
      },
      {
        id: '13',
        parentid: '1',
        name: '巴枪共配组',
        department_id: '14',
        created_at: '2022-03-11 10:35:31',
      },
      {
        id: '14',
        parentid: '1',
        name: '变现组',
        department_id: '15',
        created_at: '2022-03-11 10:35:31',
      },
      {
        id: '15',
        parentid: '1',
        name: 'H5前端组',
        department_id: '17',
        created_at: '2022-03-11 10:35:31',
      },
      {
        id: '16',
        parentid: '1',
        name: '财务部',
        department_id: '18',
        created_at: '2022-03-11 10:35:31',
      },
      {
        id: '17',
        parentid: '1',
        name: '运维监控一组',
        department_id: '19',
        created_at: '2022-03-11 10:35:32',
      },
    ];
    const result: ResponseItem = {
      code: 0,
      msg: 'success',
      data: data,
    };
    return res.json(result);
  },
  'POST /Front/getAllUsers': (req: Request, res: Response) => {
    let data = [
      {
        id: '2',
        userid: 'ZhouMing',
        name: '周明',
        mobile: '13816278310',
        status: '1',
        gender: '1',
        email: 'zhouming@kuaidihelp.com',
        avatar:
          'http://wework.qpic.cn/wwhead/duc2TvpEgSQO4BpE0WZSZz1Vae1B12aQhlMGZ2kncvVJEtuLVtIgxaEjia4NfibsjbQYcknusYZcA/0',
        created_at: '2022-03-11 10:35:32',
        menu_list: ['1', 2, 3, 4, 5, 6, 7, 8, 9, 10, '29', '104'],
        department_list: [
          {
            id: '7',
            name: '技术管理二组',
          },
          {
            id: '1',
            name: '快宝网络',
          },
        ],
      },
      {
        id: '3',
        userid: 'ZhengGui',
        name: '麻正贵',
        mobile: '13601988882',
        status: '1',
        gender: '1',
        email: '',
        avatar:
          'http://wework.qpic.cn/bizmail/N4TmQiaQXJqFveSGX9tmNXJtpRnX6FQmib9ia7Ne9mH9ducMTXzzgvlQA/0',
        created_at: '2022-03-11 10:35:32',
        menu_list: [1],
        department_list: [
          {
            id: '1',
            name: '快宝网络',
          },
          {
            id: '16',
            name: '财务部',
          },
        ],
      },
      {
        id: '4',
        userid: 'zhu',
        name: '陈珠',
        mobile: '15967129271',
        status: '1',
        gender: '2',
        email: '',
        avatar:
          'http://wework.qpic.cn/bizmail/fJUVIgOj7ID0YLONhkcZ676yE5A9KYTJBOAnKNp4wXo4vwFIm9W28w/0',
        created_at: '2022-03-11 10:35:32',
        menu_list: [],
        department_list: [
          {
            id: '1',
            name: '快宝网络',
          },
          {
            id: '16',
            name: '财务部',
          },
        ],
      },
      {
        id: '5',
        userid: 'zhangjing',
        name: '快宝驿站总部',
        mobile: '13817615862',
        status: '1',
        gender: '1',
        email: 'zhangjing@kuaidihelp.com',
        avatar:
          'https://wework.qpic.cn/wwhead/nMl9ssowtibVGyrmvBiaibzDr3GH8Gfgv6CnChp7PiaUobvjYC3UibUfn8o0LHCLlIicP5icneyAbiaiaSlE/0',
        created_at: '2022-03-11 10:35:32',
        menu_list: [],
        department_list: [
          {
            id: '2',
            name: '快宝驿站',
          },
        ],
      },
    ];
    if (req.body.department_id) {
      data = data.filter(
        (item) => !!item.department_list.find((item1) => item1.id === req.body.department_id),
      );
    }
    if (req.body.name) {
      data = data.filter((item) => item.name.includes(req.body.name));
    }
    const result: ResponseItem = {
      code: 0,
      msg: 'success',
      data: data,
    };
    return res.json(result);
  },
  'POST /Front/getInfo': (req: Request, res: Response) => {
    const result: ResponseItem = {
      code: 0,
      msg: 'success',
      data: {
        id: 1, // ID
        userid: 'zhangsan', // 企业微信 成员UserID
        name: '张三', // 成员名称
        mobile: '13838389438', // 手机号码
        status: 1, // 激活状态: 1=已激活，2=已禁用，4=未激活，5=退出企业。
        gender: 0, // 性别。0表示未定义，1表示男性，2表示女性
        email: 'zhangsan@kuaidihelp.com', // 邮箱
        avatar: 'https://img.work.wx.qq.com/avatar',
        menu_list: [1, '133-1', '133-2', 104] || [29, 61, 72, 73, 93, 104],
        created_at: '2022-03-05 10:33:44', // 创建时间
        department_list: [
          {
            //author-riverLethe-double-slash-note 用户所在的部门列表
            id: 1, // 部门id
            name: '技术部', // 部门名称
          },
        ],
      },
    };
    return res.json(result);
  },
  'POST /Front/getUserInfo': (req: Request, res: Response) => {
    const data = Mock.mock({
      id: 1, // ID
      userid: 'zhangsan', // 企业微信 成员UserID
      name: '张三', // 成员名称
      mobile: '13838389438', // 手机号码
      status: 1, // 激活状态: 1=已激活，2=已禁用，4=未激活，5=退出企业。
      gender: 0, // 性别。0表示未定义，1表示男性，2表示女性
      email: 'zhangsan@kuaidihelp.com', // 邮箱
      avatar: 'https://img.work.wx.qq.com/avatar',
      menu_list: [1, '1-1', 104],
      created_at: '2022-03-05 10:33:44', // 创建时间
      department_list: [
        {
          //author-riverLethe-double-slash-note 用户所在的部门列表
          id: 1, // 部门id
          name: '技术部', // 部门名称
        },
        {
          id: '2',
          name: '快宝驿站',
        },
      ],
    });
    const result: ResponseItem = {
      code: 0,
      msg: 'success',
      data: data,
    };
    return res.json(result);
  },
  'POST /Front/getManager': (req: Request, res: Response) => {
    const data = Mock.mock({
      id: 1, // ID
      userid: 'zhangsan', // 企业微信 成员UserID
      name: '张三', // 成员名称
      mobile: '13838389438', // 手机号码
      status: 1, // 激活状态: 1=已激活，2=已禁用，4=未激活，5=退出企业。
      gender: 0, // 性别。0表示未定义，1表示男性，2表示女性
      email: 'zhangsan@kuaidihelp.com', // 邮箱
      avatar: 'https://img.work.wx.qq.com/avatar', // 头像url
      created_at: '2022-03-05 10:33:44', // 创建时间
    });
    const result: ResponseItem = {
      code: 0,
      msg: 'success',
      data: data,
    };
    return res.json(result);
  },
  'POST /Front/updateUserAuthorize': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /Front/authorize': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /Front/sync': (req: Request, res: Response) => responseSuccess(req, res),
};
